Repository navigation
fleet-queue(fallback): contested claims age out with the lease (#6668) - #6676
Conversation
fold_claim returned Contested whenever a contest was recorded and a holder existed, regardless of lease age, and cmd_heartbeat refused the holder on a contested issue — one stray claim from a dead challenger bricked the issue for the whole backend outage (probe cases in #6660). Now: a contest older than the lease window falls through to the holder-activity fold (Live if the holder kept heartbeating, Stale/claimable if everyone went silent); a release from the challenger clears the contest in the fold; cmd_heartbeat no longer refuses the holder on a contested issue, consistent with cmd_release. Within-lease contest behavior unchanged. Three new fold tests cover the #6660 cases; doc/fleet/queue-fallback-mode.md updated.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 49 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bef9ea3a79
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // through and let the holder's last activity govern — Live | ||
| // if the holder kept heartbeating, Stale (claimable) if | ||
| // everyone went silent. | ||
| if holder.is_some() && now - ts <= lease_seconds { |
There was a problem hiding this comment.
Refresh contest activity when a challenger claims again
When a challenger posts another claim, the Claim arm leaves the existing contested timestamp unchanged because it only records a contest when contested.is_none(). With a 1800-second lease, claims from A at t=0 and B at t=60 and t=1700 produce Stale A and claimable=true at t=1861, although B's latest conflicting claim is only 161 seconds old and landed while A was live. This prematurely allows another worker to pick up disputed work, contrary to the new requirement that the challenger remain silent for a full lease. Refresh or recompute contest activity before applying expiry.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in a7c2d35: the fold now tracks challengers per-worker with each challenger's LAST conflicting claim timestamp, and a repeat claim from the same challenger refreshes its entry — a contest ages out only once every challenger has been silent for a full lease window. Covered by the new test fold_contest_repeat_claim_refreshes_and_multi_challenger (your A/B scenario: claims at t=0 / t=60 / t=LEASE-100 still fold Contested at t=60+LEASE+1). Full fleet-queue suite (--features client): 41 passed, 0 failed.
| if let Some((_, challenger, _)) = &contested { | ||
| if *challenger == ev.worker { | ||
| contested = None; |
There was a problem hiding this comment.
Preserve other active challengers when one withdraws
If multiple workers post conflicting claim markers, releasing the first challenger now clears the entire contest, including other workers' unresolved claims. For example, A claiming at t=0, B at t=60, C at t=90, and B posting a release marker at t=120 yields Live A at t=180 with a 1800-second lease, despite C's fresh conflicting claim. Previously this remained contested. Track or recompute the remaining active challengers so one worker's withdrawal does not incorrectly make disputed work safe to resume.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in a7c2d35: challengers are tracked individually in the fold, and a release now removes only the releasing challenger's contest (challengers.retain(...)) — other challengers' contests stand. Same new test covers your A/B/C scenario: B releasing at t=120 leaves the state Contested with challenger C. Full fleet-queue suite (--features client): 41 passed, 0 failed.
…sh and withdraw individually (#6668) Codex review on PR #6676 (2x P2): a repeat claim from the same challenger did not refresh the contest timestamp, so a contest could age out while the challenger was still actively claiming; and one challenger releasing cleared every challenger's contest. The fold now keeps a per-challenger last-claim list: repeat claims refresh, a release removes only that challenger, and a contest stands while any challenger has claimed within the lease window. New test fold_contest_repeat_claim_refreshes_and_multi_challenger covers both; suite 41 passed.
Fixes #6668 (follow-up to the #6660 triage probe cases).
Problem
In fallback mode (
fleet-queue/src/fallback.rs), a contested claim never expired:fold_claimreturnedContestedwhenever a contest was recorded and a holder existed — before and regardless of the lease-age check — andcmd_heartbeatrefused a contested issue, so even a live holder could not renew. If the holder was the dead worker, nobody could ever claim the issue through the tool again.Change
fold_claim, a contest older than the lease window (challenger has posted no claim for a full lease) falls through to the normal holder-activity fold —Liveif the holder kept heartbeating,Stale(claimable, clean supersede) if everyone went silent.fold_ignores_non_holder_markersstill passes).cmd_heartbeatno longer refuses the holder on a contested issue — the holder check already gates it to the holder, heartbeating is how the holder proves it is alive, andcmd_releaselikewise has no contested check, so the verbs now treatContestedconsistently.scan/statusoutput shapes unchanged.doc/fleet/queue-fallback-mode.mdcontested semantics updated.Tests
cargo test -p fleet-queue --features clienton the laptop: 40 passed, 0 failed, including 3 new fold tests for the #6660 cases:fold_contest_ages_out_with_the_lease(Case 1: both silent ~100 leases → stale/claimable; inside lease → still contested)fold_contest_holder_heartbeats_stay_live(Case 2: holder heartbeats after a contest → contest ages out to a live holder claim)fold_contest_challenger_release_clears(Case 3: challenger release + lease expiry → claimable)Existing
fold_stale_supersede_and_live_conteststill passes.cargo fmt --checkclean for the touched file (one pre-existing fmt diff in untouchedbackoff.rson main, left alone).Worked by repo-worker-code lane code-z in fallback mode (queue backend down, PostgREST PGRST002) — claim/heartbeats/release are the marker comments on #6668.
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.